﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<CRM.Database.Model.ProductMarks>>" %>
<%--<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<CRM.Models.ProductMarks>>" %>--%>
<%@ Import Namespace="CRM.Models" %>
<%@ Import Namespace="CRM.Resourses" %>
<%@ Import Namespace="System.Threading" %>
<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdProductMark";
                                        settings.KeyFieldName = "IdProductMark";
                                        settings.CallbackRouteValues = new { Controller = "Dictionaries", Action = "ProductMarksPartial" };
                                        settings.SettingsPager.PageSize = 20;

                                        //settings.Columns.Add(column =>
                                        //{
                                        //    column.Caption = "Id";
                                        //    column.FieldName = "IdProductMark";
                                        //});
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProductMarks;
                                            column.FieldName = "ProductMark";
                                        });
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.IsActive;
                                            column.FieldName = "IsActive";
                                            column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                        });

                                        //
                                        //Добавление комбобоксов
                                        //
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "IdProductVendor";
                                            column.Caption = Resourses.ProductVendors;
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;

                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                var col = new CRM.Database.Model.ProductVendorsCollection();
                                                comboBoxProperties.DataSource = col.ProductVendorsActiveList;
                                                comboBoxProperties.TextField = "LocalizedName";
                                                comboBoxProperties.ValueField = "IdProductVendor";
                                                //comboBoxProperties.DataSource = DB.GetLocalizedProductVendorsNames(Thread.CurrentThread.CurrentCulture.ToString());
                                                //comboBoxProperties.TextField = "LocaLizedString";
                                                //comboBoxProperties.ValueField = "Id";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });


                                        //
                                        //Добавление редактирования
                                        //
                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = false;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Dictionaries", Action = "ProductMarksPartialUpdate" };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Dictionaries", Action = "ProductMarksPartialAdd" };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Dictionaries", Action = "ProductMarksPartialDelete" };

                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = Unit.Percentage(100);
                                    })
       .Bind(Model).GetHtml();
%>
